function x = solve_tridiagonal(A3, B)
    a=full(diag(A3, 0))';
    b=[0,full(diag(A3, 1))'];
    c = [full(diag(A3, -1))', 0];
    n=length(a);
    q(1) = a(1);
    for i = 2:n
        p(i) = b(i)/q(i-1);
        q(i) = a(i)-p(i)*c(i-1);
    end
    y(1) = B(1);
    for i = 2:n
        y(i) = B(i)-p(i)*y(i-1);
    end
    x(n) = y(n)/q(n);
    for i = n-1:-1:1
        x(i)=(y(i)-c(i)*x(i+1))/q(i);
    end
    x=x';
end
